package com.rules.admin.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class TypeTransform {
   private static final Logger LOGGER = LoggerFactory.getLogger(TypeTransform.class);

   public static String inputStream2String(InputStream is) {
      StringBuilder sb = new StringBuilder();

      try {
         String encoding = "UTF-8";
         InputStreamReader read = new InputStreamReader(is, encoding);
         BufferedReader bufferedReader = new BufferedReader(read);

         while(true) {
            String lineTxt;
            do {
               if ((lineTxt = bufferedReader.readLine()) == null) {
                  read.close();
                  return sb.toString();
               }
            } while(lineTxt.indexOf("<!--") > -1 && lineTxt.indexOf("-->") > -1);

            sb.append(lineTxt);
         }
      } catch (Exception var6) {
         LOGGER.error("文件读取出错", var6);
         return sb.toString();
      }
   }
}
